package nowcoder;
/**
 * 24992 --井字棋
 * 链接：https://www.nowcoder.com/practice/e1bb714eb9924188a0d5a6df2216a3d1?tpId=8&&tqId=11055&rp=1&ru=/activity/oj&qru=/ta/cracking-the-coding-interview/question-ranking
 */
import java.util.*;
public class Day10_1 {
    // 1  0  1
    // 1 -1 -1
    // 1 -1  0
    public boolean checkWon(int[][] board) {
        // #字棋规则
        boolean win = true;
        // 先判断行
        for (int i = 0; i < board.length; i++) {
            win = true;
            for (int j = 0; j <board[i].length; j++) {
                if(board[i][j] != 1){
                    win = false;
                    break;
                }
            }
            if(win){
                return true;
            }
        }
        //再判断列
        for (int j = 0; j < board.length; j++) {
            win = true;
            for (int i = 0; i <board[j].length; i++) {
                if(board[i][j] != 1){
                    win = false;
                    break;
                }
            }
            if(win){
                return true;
            }
        }
        //再判断斜线
        //斜向下
        win = true;
        for (int i = 0; i < board.length; i++) {
            if(board[i][i] != 1){
                win = false;
                break;
            }
        }
        if(win){
            return true;
        }
        //斜向上
        win = true;
        for (int i = 0; i < board.length; i++) {
            if(board[i][board.length - i - 1] != 1){
                win = false;
                break;
            }
        }
        return win;
    }
}
